<template>
  <div :class="['nav', { 'is-active': fold }]">
    <!-- 折叠展开按钮 -->
    <div :class="['fold', { 'is-active': fold }]" @click="handlerToggleFold">
      <div></div>
      <div></div>
      <div></div>
    </div>
    <!-- logo -->
    <div :class="['logo', { 'is-active': fold }]">logo</div>
  </div>
</template>

<script lang="ts">
import { defineComponent, reactive, ref } from 'vue'
export default defineComponent({
  name: 'home-nav',
  setup() {
    let fold = ref(true)
    function handlerToggleFold() {
      fold.value = !fold.value
    }
    return { fold, handlerToggleFold }
  },
})
</script>

<style lang="scss" scoped>
.nav {
  position: relative;
  width: 60px;
  height: 100vh;
  transition: 0.5s;
  box-shadow: 2px 0 2px #ccc;

  &.is-active {
    width: 200px;
  }

  .fold {
    position: absolute;
    right: -50px;
    width: 50px;
    height: 50px;
    // background: blue;
    cursor: pointer;

    div {
      margin-bottom: 5px;
      margin-left: 13px;
      width: 18px;
      height: 3px;
      background: #000;
      border-radius: 3px;
      box-shadow: 0 0 2px #000;
      transition: 0.5s;
      &:first-child {
        margin-top: 15.5px;
        transform: rotateZ(40deg) translate(2px, 2px);
      }

      &:nth-child(2) {
        transform: translateX(-2px);
      }

      &:last-child {
        transform: rotateZ(-40deg) translate(2px, -2px);
      }
    }

    &.is-active div {
      width: 24px;
      transform: initial;
    }
  }

  .logo {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 50px;
    text-align: center;
    line-height: 50px;
    font-style: italic;
    font-weight: bold;
    font-size: 20px;
    // color: #fff;
    text-shadow: 0 0 3px #000;
    border-bottom: 1px solid rgb(201, 136, 82);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
      'Open Sans', 'Helvetica Neue', sans-serif;
    transition: 0.5s;

    &::before {
      position: absolute;
      left: 0;
      content: '';
      width: 5%;
      height: 100%;
      background: rgba(255, 255, 255, 0.7);
      border-radius: 50%;
      transform: rotateZ(20deg);
      // animation: highlight 3s linear infinite;
    }

    &.is-active {
      font-size: 30px;
    }

    @keyframes highlight {
      0% {
        left: 0;
      }

      30%,
      100% {
        left: calc(100% + 20px);
      }
    }
  }
}
</style>
